package com.ryskoo.framework.core.consumer;

import com.ryskoo.common.dto.BasicDTO;
import com.ryskoo.framework.core.bean.QueryMessageDTO;
import com.ryskoo.framework.core.bean.ReturnCodeEnum;
import com.ryskoo.framework.core.bean.ReturnMessageDTO;

import java.util.List;

public class BasicConsumerHystrix<DTO extends BasicDTO> implements BasicConsumer<DTO> {

	@Override
	public ReturnMessageDTO<DTO> getById(String id) {
		return timeoutMessageDTO();
	}

	@Override
	public ReturnMessageDTO<List<DTO>> getAll() {
		return timeoutMessageDTO();
	}

	@Override
	public ReturnMessageDTO<List<DTO>> getList(QueryMessageDTO queryMessage) {
		return timeoutMessageDTO();
	}

	@Override
	public ReturnMessageDTO<DTO> create(DTO dto) {
		return timeoutMessageDTO();
	}

	@Override
	public ReturnMessageDTO<DTO> update(DTO dto) {
		return timeoutMessageDTO();
	}

    @Override
    public ReturnMessageDTO delete(List<String> idList) {
        return timeoutMessageDTO();
    }
    
	@Override
	public ReturnMessageDTO<List<DTO>> getListAll(QueryMessageDTO queryMessage) {
		return timeoutMessageDTO();
	}

    public ReturnMessageDTO timeoutMessageDTO() {
		ReturnMessageDTO returnMessage = new ReturnMessageDTO();
		returnMessage.setReturnCode(ReturnCodeEnum.TIMEOUT.getReturnCode());
		returnMessage.setReturnNote("服务异常, 请稍后再试");
		return returnMessage;
	}
}
